﻿/*
// Exepack.NET compressor
// http://www.codeplex.com/exepack
//
// About box
// Written by Y [22-02-10]
// Copyright (c) 2008-2010 Alexey Yakovlev
*/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Reflection;
using BLToolkit;
using Mono.Cecil;
using Vestris.ResourceLib;

namespace Exepack
{
	/// <summary>
	/// About Exepack.NET
	/// </summary>
	public partial class AboutForm : Form
	{
		public AboutForm(Form parentForm)
		{
			InitializeComponent();

			Text += ", version " + GetType().Assembly.GetName().Version;
			LogoBox.Image = Icon.ExtractAssociatedIcon(Application.ExecutablePath).ToBitmap();

			SetLocation(parentForm);
			DisplayLibraries();
		}

		void SetLocation(Form parentForm)
		{
			if (parentForm != null && parentForm.Visible)
			{
				Left = parentForm.Left + (parentForm.Width - Width) / 2;
				Top = parentForm.Top + (parentForm.Height - Height) / 2;
			}
		}

		void DisplayLibraries()
		{
			// list of libraries used
			var asms = new List<Assembly>();
			asms.Add(typeof(EmitHelper).Assembly);
			asms.Add(typeof(AssemblyDefinition).Assembly);
			asms.Add(typeof(ResourceInfo).Assembly);

			foreach (var asm in asms)
			{
				var item = new ListViewItem(asm.GetName().Name);
				item.SubItems.Add(asm.GetName().Version.ToString());
				LibsListView.Items.Add(item);
			}
		}

		private void UrlLbl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			Process.Start(UrlLbl.Text);
		}
	}
}
